<template>
    <div class="box">
      <!-- <form action="/">
        <van-search
    v-model="value"
    placeholder="请输入搜索关键词"
    input-align="center"
    style="margin-top: 48px;"
    shape="round"
  />
  </form> -->
  
  <van-list
    v-model="loading"
    :finished="finished"
    finished-text="没有更多了"
    @load="onLoad"
  >
  <div v-for='(item, index) in list' :key="index"> 
    <!-- <div @click="toShop"> -->
      <div>
    <van-card
    :desc="item.description"
    :title="item.classname"
    :thumb="thumb"
    @click="toMemberList(index)"
  >
  </van-card>
  </div>
  </div>
  </van-list>
    </div>
  </template>
  
  <script>
  import { Toast } from 'vant';
import axios from 'axios';
  
  export default {
    name: 'IndexList',
    data() {
      return {
        value: '',
        thumb: 'https://img.yzcdn.cn/vant/cat.jpeg',
        list: [],
        loading: false,
        finished: false,
        fin:0,
      };
    },
    mounted() {
      this.loading = false;
      axios.post("/class/classlist?userId="+localStorage.getItem('userId')).then(res => {
        // console.log(res);
        console.log(res.data.data.code);
        this.list = res.data.data;
        // console.log(this.list);
      });
    },
    methods: {
      // titleName(){
      //   eventBus.$emit('titleName', this.list[0].title);
      // },
      onSearch(val) {
        Toast(val);
      },
      onLoad() {
      setTimeout(() => {
        for (let i = 0; i < 100; i++) {
          this.fin += 1;
        }
        this.loading = false;
        if (this.fin >= this.list.length) {
          this.finished = true;
        } 
        if (res.data.data === null) {
          this.finished = true;
        }
      }, 1000);
    },
      toMemberList(title){
        // EventBus.$emit('titleName', this.list[0].title);
        this.$router.push('/Scoring/main/' + this.list[title].classname+'/'+this.list[title].id);  
      }
      // onCancel() {
      //   Toast('取消');
      // },
    },
  };
  </script>
  
  <style scoped lang="less">
  ::v-deep .van-card__title {
    font-size: 500px;
    // background-color: black;
  }
  ::v-deep .van-card__desc {
    font-size: 500px;
    background-color: white;
  }
  </style>